<?php
use yii\helpers\Url;
use yii\web\View;
use app\assets\NewCreativeTemplateAsset;
NewCreativeTemplateAsset::register($this);
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$this->params['breadcrumbs'] = [
  [
    'label' => '创意模板列表',
    'url' => ['index']
  ],
  '编辑创意模板'
];
?>
<div class="page-header">
  <h1>
    创意模板
    <small>编辑模板</small>
  </h1>
</div>
<div class="panel panel-default">
  <div class="panel-heading">
    <i class="fa fa-plus-circle"></i>
    编辑创意模板
    <ul class="list-unstyled pull-right">
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
	<div class="panel-body">
		<div class="row">
			<div class="col-sm-8 col-sm-offset-2">
        <form action="<?= Url::to(['new-creative-template-handle']);?>" class="form-horizontal" id="data-frm">
          <input class="hidden" type="text" name="id" value="">
          <fieldset>
            <legend>创意模板信息</legend>
            <div class="form-group">
              <label for="creative_template_name" class="col-sm-3 control-label">
                <em>*</em>
                模板名称：
              </label>
              <div class="col-sm-9">
                <input type="text" class="form-control" id="creative_template_name" value="" placeholder="模板名称">
                <div class="help-block text-error" id="creative_template_name_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label for="crowd_tag" class="col-sm-3 control-label">
                <em>*</em>
                人群标签：
              </label>
              <div class="col-sm-9">
                <input type="text" class="form-control" id="crowd_tag" value="" placeholder="人群标签">
                <div class="help-block text-error" id="crowd_tag_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label for="crowd_tag" class="col-sm-3 control-label">
                <em>*</em>
                选择模板：
              </label>
              <div class="col-sm-9">
                <select id="templateContent" class="form-control" name="tmeplate_content" >
                  <option value="system" selected>系统模板</option>
                </select>
              </div>
            </div>
          </fieldset>
          <fieldset>
            <legend>动态元素</legend>
            <div class="form-group">
              <label for="logo_pic" class="col-sm-3 control-label">
                <em>*</em>
                Logo：
              </label>
              <div class="col-sm-7">
                <div class="creative-preview">
                </div>
                <img class="img-thumbnail creative_material_default" id="creative_logo_default" src="holder.js/310x260/text:未上传" alt="未上传">
                <input id="upload_logo" name="upload_logo" type="hidden" value="">
                <div class="help-block text-error" id="upload_logo_err"></div>
              </div>
              <div class="col-sm-2">
                <button class="btn btn-info upload-operate-btn" id="upload-logo" data-type="logo" type="button">
                  <i class="fa fa-upload"></i>
                  上传
                </button>
              </div>
            </div>
            <div class="form-group">
              <label for="logo_click_url" class="col-sm-3 control-label">
                <em>*</em>
                Logo点击地址：
              </label>
              <div class="col-sm-9">
                <input class="form-control" id="logo_click_url" type="text" name="logo_click_url" value="" placeholder="http(s)://">
                <div class="help-block text-error" id="logo_click_url_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label for="backup_material" class="col-sm-3 control-label">
                <em>*</em>
                打底图：
              </label>
              <div class="col-sm-7">
                <div class="creative-preview">
                </div>
                <img class="img-thumbnail creative_material_default" id="creative_backup_default" src="holder.js/310x260/text:未上传" alt="未上传">
                <input id="upload_backup" name="upload_backup" type="hidden" value="">
                <div class="help-block text-error" id="upload_backup_err"></div>
                <div class="help-block">请上传和模板同尺寸的静态打底图，大小要求参考各Exchange对创意的要求。</div>
              </div>
              <div class="col-sm-2">
                <button class="btn btn-info upload-operate-btn" id="upload-backup" data-type="backup" type="button">
                  <i class="fa fa-upload"></i>
                  上传
                </button>
              </div>
            </div> 
            <div class="form-group">
              <label for="backup_click_url" class="col-sm-3 control-label">
                <em>*</em>
                打底图点击地址：
              </label>
              <div class="col-sm-9">
                <input class="form-control" id="backup_click_url" type="text" name="backup_click_url" value="" placeholder="http(s)://">
                <div class="help-block text-error" id="backup_click_url_err"></div>
              </div>
            </div> 
            <!-- <div class="form-group">
              <label for="thumbnail_material" class="col-sm-3 control-label">
                缩列图：
              </label>
              <div class="col-sm-7">
                <div class="creative-preview">
                </div>
                <img class="img-thumbnail" id="creative_material_default" src="holder.js/310x260/text:未上传" alt="未上传">
                <input id="upload_material" name="upload_material" type="hidden" value="">
                <div class="help-block text-error" id="upload_material_err"></div>
              </div>
              <div class="col-sm-2">
                <button class="btn btn-info" id="upload-material" type="button">
                  <i class="fa fa-upload"></i>
                  上传
                </button>
              </div>
            </div> -->
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-10">
                <div class="btn-form-group pull-right">
                  <button type="submit" class="btn btn-primary" data-loading-text="<i class='fa fa-spinner fa-spin'></i> 数据提交中...">保存</button>
                  <a href="<?php echo Url::to(['creative-template/index']); ?>" class="btn btn-default">返回列表</a>
                </div>
              </div>
            </div>
          </fieldset>
        </form>
      </div>
		</div>
	</div>
</div>
<div class="modal fade" id="upload-material-modal">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title">上传素材</h4>
      </div>
      <div class="modal-body">
        <div class="portlet-content">
          <span class="btn btn-success btn-sm fileinput-button">
            <i class="fa fa-plus"></i>
            <span>选择文件</span>
            <input id="creative-id" type="hidden" name="creative_id" value="${id}" >
            <!-- The file input field used as target for the file upload widget -->
            <input type="file" multiple="" name="files[]" id="fileupload">
          </span>
          <br>
          <br>
          <!-- The global progress bar -->
          <div class="progress" id="progress">
              <div aria-valuemax="100" aria-valuemin="0" class="progress-bar progress-bar-success progress-bar-striped">0%</div>
          </div>
          <!-- The container for the uploaded files -->
          <div class="files" id="files">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>ID</th>
                  <th>文件名称</th>
                  <th>文件大小(KB)</th>
                  <th>上传时间</th>
                  <th>判断信息</th>
                  <th>上传者</th>
                </tr>
              </thead>
              <tbody></tbody>
              </table>
            </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="upload-confirm-operate" data-type="" data-material-id="">确定</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php
  // $uploadMaterialUrl = Url::to(['creative/upload-pic']);
  $uploadMaterialUrl = Yii::getAlias('@web').'/response/creative/uploadMaterialDataList.php';
  // $creativeVocation = $categories;
  //$creativeVocation = '{"汽车":["车讯行情","车辆养护","配件改装","其它"],"新闻":["军事","时政要闻","产经","科技","其它"],"财经":["股票","基金","理财","房产","保险","收藏","其它"],"数码":["电脑","手机","数码设备","软件","APP","其它"],"医疗":["健康养生","疾病治疗","整形美容","两性","其它"],"娱乐影音":["影视","音乐","图书","图片","星座","明星","游戏","宠物","休闲活动","其它"],"社交与网络服务":["婚恋交友","SNS","论坛","网络服务"],"教育":["幼教","应试","考研","培训","MBA","出国","自考","其它"],"家居家电":["家电","家具","装修","装饰","日常用品"],"体育":["足球","篮球","网球","户外","健身","器材","其它"],"旅行":["酒店和住宿","旅行社和服务","票务服务"],"女性":["时尚","美容","母婴"],"职业":["简历","招聘信息","其它"],"食品饮料":["美食","零食","饮料","烟酒","保健食品","其它"],"服饰鞋包":["服装","鞋靴","配饰","珠宝首饰","箱包","钟表","奢侈品","眼镜"],"工农业":["电子电工","机械设备","农林牧渔","化工及材料"],"生活和商务服务":["生活服务","商务服务"]}';
  $this->registerJs("VAM.setVar('UPLOAD_MATERIAL_URL','$uploadMaterialUrl');", View::POS_HEAD);
  // $this->registerJs("VAM.setVar('CREATIVE_VOCATION','$creativeVocation')", View::POS_HEAD);
?>
<script type="text/javascript" >
  requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/creativeTemplate/newCreativeTemplate.js"]);
  });
</script>